﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoCode.Win
{
    /// <summary>
    /// 额外的Table处理帮助
    /// </summary>
    public class TableHelper
    {
        /// <summary>
        /// 获取类型
        /// 主要是用于判断是否可空字段
        /// </summary>
        /// <param name="type"></param>
        /// <param name="isnull"></param>
        /// <returns></returns>
        public static string GetType(string type,string must)
        {
            string t = type.ToLower(); bool ifnull = !Convert.ToBoolean(must);
             string r =   ((t == "short" || t == "int" || t == "decimal" || t == "double" || t == "bool" || t == "datetime") 
                            ? (ifnull == true ? type + "?" : type) : type);
            return r;
        }

        /// <summary>
        /// 表外键约定转换
        /// </summary>
        /// <param name="outtableinfo"></param>
        /// <returns></returns>
        public static OutTableInfo GetTable(string outtableinfo)
        {
            string[] info = outtableinfo.Split('#');
            OutTableInfo i = new OutTableInfo();
            i.OutTable= info[0];
            if (info.Length > 1)
            {
                i.TableFiled = info[1];
            }
            else
            {
                i.TableFiled = "";
            }
            return i;
        }
        ////检查表ID标识字段类型
        //public static string CheckTableIDType(string tablename)
        //{
        //    //
        //    if (Properties.Settings.Default.longIDTable.Trim(',').Split(',').Contains(tablename))
        //    {
        //        return "long";
        //    }
        //    else
        //    {
        //        return "int";
        //    }
        //}


        public static string GetActionInfo(string ActionName)
        {
            string ActionNote = string.Empty;
            switch (ActionName)
            {
                case "exist":
                    ActionNote = "";
                    break;
                case "add":
                    ActionNote = "";
                    break;
                case "update":
                    ActionNote = "";
                    break;
                case "delete":
                    ActionNote = "";
                    break;
                case "get":
                    ActionNote = "";
                    break;
                case "maxid.get":
                    ActionNote = "";
                    break;
                case "list.delete":
                    ActionNote = "";
                    break;
                case "list.get":
                    ActionNote = "";
                    break;
                case "count.get":
                    ActionNote = "";
                    break;
            }
            return ActionNote;
        }
    }


}
